home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 May: Tool Chest / Developer CD Series May 1996 (Tool Chest) (Apple Computer) (1996).iso / Tool Chest / Testing & Debugging / Debuggers & dcmds / MacsBug 6.5.2 / dcmds / C Samples / Where.c < prev   
Encoding:
C/C++ Source or Header  |  1995-07-26  |  2.0 KB  |  85 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        Where.c
  3.  
  4.     Contains:    A sample dcmd which displays information about a trap or address.
  5.  
  6.     Written by:    JM3 = Jim Murphy
  7.  
  8.     Copyright:    © 1991, 1994 by Apple Computer, Inc., All Rights Reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.          <3>   11-Dec-94    JM3        Bleh. I somehow deleted a couple of lines at the end.
  13.          <2>   10-Dec-94    JM3        Updated for new version 3 dcmd requirements.
  14.  
  15.  
  16.    The following MPW commands will build the dcmd and copy it to the
  17.    "Debugger Prefs" file in the System folder. The dcmd's name in
  18.    MacsBug will be the name of the file built by the Linker.
  19.  
  20.         C Where.p
  21.         Link {dcmdLib}dcmdGlue.a.o Where.c.o {dcmdLib}DRuntime.o -o Where
  22.         BuildDcmd Where 102
  23.         Echo 'include "Where";'    |    Rez -a -o "{systemFolder}Debugger Prefs"
  24.  */
  25.  
  26. #include <Memory.h>
  27. #include <Types.h>
  28. #include "dcmd.h"
  29.  
  30.  
  31. pascal void CommandEntry (dcmdBlock* paramPtr)
  32. {
  33.  
  34.     short    ch;
  35.     long    address;
  36.     Boolean    ok;
  37.     Str255    name;
  38.  
  39.     static const char usageStr[] = "\p[addr | trap]";
  40.  
  41.     switch (paramPtr->request)
  42.     {
  43.         case dcmdInit:
  44.             break;
  45.  
  46.         case dcmdHelp:
  47.             dcmdDrawLine("\pDisplay information about the address or trap.");
  48.             dcmdDrawLine("\pIf no parameter then use PC as the address.");
  49.             break;
  50.  
  51.         case dcmdGetInfo:
  52.             * (long *) &((GetInfoRequestBlockPtr) paramPtr->requestIOBlock)->dcmdVersion = 0x03008000; // version 3.0 final
  53.             BlockMoveData(&usageStr, &((GetInfoRequestBlockPtr) paramPtr->requestIOBlock)->usageStr, usageStr[0]+1);
  54.             break;
  55.  
  56.         case dcmdDoIt:
  57.             if (dcmdPeekAtNextChar () == '\n')
  58.                 address = paramPtr->registerFile[PCRegister];
  59.             else
  60.             {
  61.                 ch = dcmdGetNextExpression (&address, &ok);
  62.                 if (!ok)
  63.                 {
  64.                     dcmdDrawLine ("\pSyntax error");
  65.                     return;
  66.                 }
  67.             }
  68.  
  69.             if (address >= 0x0000A000 && address <= 0x0000ABFF)
  70.             {
  71.                 dcmdGetTrapName (address, name);
  72.                 dcmdDrawLine (name);
  73.             }
  74.             else
  75.             {
  76.                 dcmdGetNameAndOffset (address, name);
  77.                 if (name[0] > 0)
  78.                     dcmdDrawLine (name);
  79.                 else
  80.                     dcmdDrawLine ("\pNo procedure name found");
  81.             }
  82.             break;
  83.         }
  84. } // CommandEntry
  85.